/*
 * RoleService.java
 *
 * Copyright 2012 the original author or authors(ninglong).
 *
 * Licensed under the web-geek, Version 1.0 (the "License");
 *
 */
package org.geek.role.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.geek.common.entity.Criteria;
import org.geek.domain.Role;
import org.geek.role.mapper.RoleMapper;
import org.geek.role.service.IRoleService;
import org.springframework.stereotype.Service;

/**
 * <p></p>
 * @author ninglong bhd2973@qq.com
 * @version V1.0
 */
@Service
public class RoleService implements IRoleService {

	@Resource
	private RoleMapper roleMapper;
	@Override
	public int countRoleByCriteria(Criteria criteria) {
		return roleMapper.countRoleByCriteria(criteria);
	}

	@Override
	public List<Role> getRoleByCriteria(Criteria criteria) {
		return roleMapper.getRoleByCriteria(criteria);
	}

	@Override
	public int addRole(Role role) {
		return roleMapper.addRole(role);
	}
	
	@Override
	public int modRole(Role role) {
		return roleMapper.modRole(role);
	}

	@Override
	public int delRoleByRoleId(int roleId) {
		int i = roleMapper.delRoleByRoleId(roleId);
		i = i + roleMapper.delRoleAndUserByRoleId(roleId);//删除角色后,将t_user_role表中与该角色相关的数据删除
		i = i + roleMapper.delRoleAndModuleByRoleId(roleId);//删除角色后,将t_role_module表中与该角色相关的数据删除
		return i;
	}

}
